package Interfaces;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class LabelSwitcher {
	JPanel pannello = null;
	String testo;
	DividiStateObservers myNP;
	
	public JPanel crea(String s, DividiStateObservers mynp, final boolean in_out)
	{
		myNP=mynp;
		testo=s;
		pannello = new JPanel();
		pannello.add(new JLabel(testo));
		pannello.addMouseListener(new MouseListener()
		{	
			@Override public void mouseReleased(MouseEvent arg0) {}
			
			@Override public void mousePressed(MouseEvent arg0) {}
			
			@Override public void mouseExited(MouseEvent arg0) {}
			
			@Override public void mouseEntered(MouseEvent arg0) {}
			
			@Override public void mouseClicked(MouseEvent arg0) 
			{ 
				if(in_out)
				{
					if(myNP.ListaSOScelti.size()!=14)
					{
						myNP.ListaSODisponibili.remove(testo);
						myNP.ListaSOScelti.add(testo);
						myNP.redisplay();
					}
				}
				else
				{
					myNP.ListaSODisponibili.add(testo);
					myNP.ListaSOScelti.remove(testo);
					myNP.redisplay();
				}
			}
		});
		return pannello;
	}
	public JPanel crea (String s, int ruolo)
	{
		testo=s;
		pannello = new JPanel();
		pannello.add(new JLabel(testo));
		
		return pannello;
	}
}
